package com.example.yyjc.service.impl;

import com.example.yyjc.domain.User;
import com.example.yyjc.mapper.UserMapper;
import com.example.yyjc.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author lvyongwei
 * @Date 2020-11-10 9:56
 **/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 判断登录名是否重复
     * @param loginName
     * @return
     */
    @Override
    public User verifyLoginName(String loginName) {
        return userMapper.verifyLoginName(loginName);
    }

    /**
     * 判断手机号是否重复
     * @param phone
     * @return
     */
    @Override
    public User verifyPhone(String phone) {
        return userMapper.verifyPhone(phone);
    }

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    @Override
    public boolean updateUser(User user) {
        return userMapper.updateUser(user);
    }

    /**
     * 添加用户信息
     * @param user
     * @return
     */
    @Override
    public boolean insertUser(User user) {
        return userMapper.insertUser(user);
    }

    /**
     * 根据用户名获取用户信息
     * @param loginName
     * @return
     */
    @Override
    public User getUserByLoginName(String loginName) {
        return userMapper.getUserByLoginName(loginName);
    }

    /**
     * 修改密码
     * @param password
     * @param phone
     * @return
     */
    @Override
    public User updatePassword(String phone, String password) {
        return userMapper.updatePassword(phone,password);
    }

    /**
     * 游客登录插入一条游客信息
     * @param user
     * @return
     */
    @Override
    public boolean insertTourists(User user) {
        return userMapper.insertTourists(user);
    }

    /**
     * 查询所有用户信息
     * @param user
     * @return
     */
    @Override
    public List<User> getAllUser(User user) {
        return userMapper.getAllUser(user);
    }

    /**
     * 导出用户信息
     * @param data
     * @return
     */
    @Override
    public List<User> importUser(String data) {
        return userMapper.importUser(data);
    }
}
